import type { RouteRecordRaw } from 'vue-router';

import { DefaultLayout } from '@/fierce/layouts';

const commonPages: RouteRecordRaw[] = [
  {
    name: 'ssoLogin',
    path: '/sso',
    component: () => import('@/pages/common/sso/index.vue'),
    meta: {
      title: '单点登录',
      keepAlive: false,
      affix: false,
    },
  },
  {
    name: 'authorizationPage',
    path: '/authorization',
    component: () => import('@/pages/common/authorization/index.vue'),
    meta: {
      title: '系统授权',
      keepAlive: false,
      affix: false,
    },
  },
  {
    path: '/common',
    component: DefaultLayout,
    children: [
      {
        name: 'userSetting',
        path: 'user-setting',
        component: () => import('@/pages/common/user-setting/index.vue'),
        meta: {
          title: '用户信息设置',
          keepAlive: false,
          affix: false,
        },
      },
      {
        name: 'myMessages',
        path: 'my-messages',
        component: () => import('@/pages/common/my-messages/index.vue'),
        meta: {
          title: '我的通知',
          keepAlive: false,
          affix: false,
        },
      },
      {
        name: 'ViewMessages',
        path: 'view-messages',
        component: () => import('@/pages/common/my-messages/view-messages.vue'),
        meta: {
          title: '查看通知',
          keepAlive: false,
          affix: false,
        },
        beforeEnter: (to, _, next) => {
          const name = to.query.name;
          if (name) {
            to.meta.title = `通知-(${name})`;
          } else {
            to.meta.title = '查看通知';
          }
          next();
        },
      },
    ],
  },
];

export default commonPages;
